#include "Rectangle.h"
namespace sffs {

// Constructor()
Rectangle::Rectangle()
{
	m_Shape.AddPoint(0.0f, 0.0f, m_Color, sf::Color(0,0,0)) ;
	m_Shape.AddPoint(0.0f, 0.0f, m_Color, sf::Color(0,0,0)) ;
	m_Shape.AddPoint(0.0f, 0.0f, m_Color, sf::Color(0,0,0)) ;
	m_Shape.AddPoint(0.0f, 0.0f, m_Color, sf::Color(0,0,0)) ;
	m_Shape.EnableFill(true) ;
	m_Shape.SetColor(m_Color) ;
	m_Shape.EnableOutline(true) ;
	m_Shape.SetOutlineWidth(0.0f) ;
}

// Constructor(pair<float,float>, pair<float,float>, pair<float,float>, sf::Color)
Rectangle::Rectangle(const std::pair<float, float>& _Center, const std::pair<float, float>& _WH, const sf::Color& _Color)
	: m_Color(_Color)
	, m_Center(_Center)
{
	m_Shape.AddPoint(_Center.first-_WH.first/2, _Center.second-_WH.second/2, m_Color, sf::Color(0,0,0)) ;
	m_Shape.AddPoint(_Center.first+_WH.first/2, _Center.second-_WH.second/2, m_Color, sf::Color(0,0,0)) ;
	m_Shape.AddPoint(_Center.first+_WH.first/2, _Center.second+_WH.second/2, m_Color, sf::Color(0,0,0)) ;
	m_Shape.AddPoint(_Center.first-_WH.first/2, _Center.second+_WH.second/2, m_Color, sf::Color(0,0,0)) ;
	m_Shape.EnableFill(true) ;
	m_Shape.SetColor(m_Color) ;
	m_Shape.EnableOutline(true) ;
	m_Shape.SetOutlineWidth(0.0f) ;
}

// Destructor
Rectangle::~Rectangle()
{
}

// SetCenter
void Rectangle::SetCenter(float _X, float _Y)
{
	m_Center.first = _X ;
	m_Center.second = _Y ;
	m_Shape.SetPointPosition(0, _X-m_WH.first/2, _Y-m_WH.second/2) ;
	m_Shape.SetPointPosition(1, _X+m_WH.first/2, _Y-m_WH.second/2) ;
	m_Shape.SetPointPosition(2, _X+m_WH.first/2, _Y+m_WH.second/2) ;
	m_Shape.SetPointPosition(3, _X-m_WH.first/2, _Y+m_WH.second/2) ;
}

// SetWidthHeight
void Rectangle::SetWidthHeight(float _X, float _Y)
{
	m_WH.first = _X ;
	m_WH.second = _Y ;
	m_Shape.SetPointPosition(0, m_Center.first-_X/2, m_Center.second-_Y/2) ;
	m_Shape.SetPointPosition(1, m_Center.first+_X/2, m_Center.second-_Y/2) ;
	m_Shape.SetPointPosition(2, m_Center.first+_X/2, m_Center.second+_Y/2) ;
	m_Shape.SetPointPosition(3, m_Center.first-_X/2, m_Center.second+_Y/2) ;
}

// SetColor
void Rectangle::SetColor(int _R, int _G, int _B)
{
	m_Color = sf::Color(_R, _G, _B) ;
	m_Shape.SetColor(m_Color) ;
	m_Shape.SetPointColor(0, m_Color) ;
	m_Shape.SetPointColor(1, m_Color) ;
	m_Shape.SetPointColor(2, m_Color) ;
	m_Shape.SetPointColor(3, m_Color) ;
}

// Draw
void Rectangle::Draw() const
{
	Drawable::m_Window->Draw(m_Shape) ;
}

void Rectangle::ChangeColor(int newTime)
{

}

} // namespace sffs